home *** CD-ROM | disk | FTP | other *** search
- /*
- * rawrite for Human68k
- * -- Write a binary image to 1200K diskette.
- * by Masaru Oki
- *
- * Usage:
- * Human prompt> RAWRITE
- *
- * And follow the prompts.
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <sys/dos.h>
- #include <sys/param.h>
- #include <ctype.h>
-
- int
- main()
- {
- char fname[MAXPATHLEN];
- FILE *fp;
- int siz;
- char *adr;
- char drive;
-
- printf("RaWrite 1.2 - Write disk file to raw floppy diskette\n");
- printf("Enter source file name: ");
- scanf("%s", fname);
- fp = fopen(fname, "rb");
- if (fp == NULL) {
- perror(fname);
- exit(1);
- }
-
- printf("Enter destination drive: ");
- scanf("%s", fname);
- drive = fname[0];
- drive = (islower(drive) ? toupper(drive) : drive) - 'A';
- printf("Please insert a formatted diskette into ");
- printf("drive %c: and press -ENTER- :", drive + 'A');
- fflush(stdin);
- getchar();
-
- fseek(fp, 0, SEEK_END);
- siz = ftell(fp);
- fseek(fp, 0, SEEK_SET);
- adr = malloc(siz);
- if (adr == NULL) {
- perror("malloc");
- exit(1);
- }
- printf("Reading image");
- fread(adr, 1, siz, fp);
- fclose(fp);
-
- printf("\nWriting image to drive %c:", drive+'A');
- _dos_diskwrt2(adr, drive + 1, 0, siz / 512);
- printf("\nDone.\n");
-
- return 0;
- }
-